<template>
	<view class="app-pages">
		<view class="title">发票详情</view>
			<u--form labelPosition="left" :model="form" :rules="rules" ref="uForm" labelWidth="140rpx">
				<u-form-item label="抬头类型:" prop="name">
					<u-radio-group v-model="form.name" placement="row">
						<u-radio label="苹果" name="苹果" />
						<u-radio :customStyle="{marginLeft: '8px'}" label="香蕉" name="香蕉" />
					</u-radio-group>
				</u-form-item>

				<u-form-item label="发票抬头:" prop="name">
					<u--input v-model="form.name" border="surround"></u--input>
				</u-form-item>

				<u-form-item label="发票税号:" prop="name" v-if="type == '1'">
					<u--input v-model="form.name" border="surround"></u--input>
				</u-form-item>

				<u-form-item label="联系地址:" prop="name" v-if="type == '1'">
					<u--input v-model="form.name" border="surround"></u--input>
				</u-form-item>

				<u-form-item label="联系电话:" prop="name" v-if="type == '1'">
					<u--input v-model="form.name" border="surround"></u--input>
				</u-form-item>

				<u-form-item label="开户银行:" prop="name" v-if="type == '1'">
					<u--input v-model="form.name" border="surround"></u--input>
				</u-form-item>

				<u-form-item label="银行账号:" prop="name" v-if="type == '1'">
					<u--input v-model="form.name" border="surround"></u--input>
				</u-form-item>

				<u-form-item label="接收邮箱:" prop="name">
					<u--input v-model="form.name" border="surround"></u--input>
				</u-form-item>
			</u--form>
			
			<view class="title">发票设置</view>
			<view class="switch">
				<view class="">
					<view class="">设置为默认抬头</view>
					<view class="">每次开票会默认填写该抬头信息</view>
				</view>
				<u-switch v-model="value" activeColor="#f56c6c"></u-switch>
			</view>
			
		<u-button @click="submit">提交</u-button>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				type: '',
				value: true,
				form: {
					name: ''
				},
				rules: {
					name: {
						required: true,
						message: '请输入姓名',
						trigger: ['blur', 'change']
					}
				},
			}
		},
		onLoad(options) {
			this.type = options.type
		},
		methods: {
			submit() {
				this.$refs.uForm.validate().then(res => {
					uni.$u.toast('校验通过')
				}).catch(errors => {
					uni.$u.toast('校验失败')
				})
			}
		}
	}
</script>
<style lang="scss" scoped>
	.title {
		font-size: 32rpx;
		font-weight: bold;
		padding: 20rpx 0;
	}
	.switch{
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 30rpx 0;
	}
</style>
